package com.hcb.controller;

import com.hcb.common.ActionEvent;
import com.hcb.constants.Constants;
import com.hcb.fragment.EmergencyContactsFragment;
import com.hcb.model.utils.ContactModel;

public class ContactController {
	public static ContactController instance;

	public static ContactController getInstance() {
		if (instance == null)
			instance = new ContactController();
		return instance;
	}

	public void handleViewEvent(ActionEvent e) {
		switch (e.action) {
		case Constants.GET_CONTACT:
			ContactModel.getInstance().handleControllerEvent(e);
			break;
		case Constants.INSERT_CONTACT: {
			ContactModel.getInstance().handleControllerEvent(e);
			break;
		}
		case Constants.INSERT_CONTACT_EXITS: {
			ContactModel.getInstance().handleControllerEvent(e);
			break;
		}
		case Constants.UPDATE_CONTACT: {
			ContactModel.getInstance().handleControllerEvent(e);
			break;
		}

		case Constants.DELETE_CONTACT: {
			ContactModel.getInstance().handleControllerEvent(e);
			break;
		}

		default:
			break;
		}
	}

	public void handleModelViewEvent(ActionEvent e) {
		switch (e.action) {
		case Constants.GET_CONTACT:
			EmergencyContactsFragment sender = (EmergencyContactsFragment) e.sender;
			sender.handleControllerViewEvent(e);
			break;

		default:
			break;
		}
	}
}
